package recursion;

public class RecursionDemo02 {
    public static void main(String[] args) {
        System.out.println(getFactorial(4));
        System.out.println(getFactorial(6));

        System.out.println(getFactorial02(5));
        System.out.println(getFactorial02(6));
    }

    public static int getFactorial(int n) {
        int sum = 1;
        for (int i = n; i > 1; i--) {
            sum *= i;
        }
        return sum;
    }

    public static int getFactorial02(int n) {
        if (n == 0 || n == 1) {
            return 1;//递归出口
        }
        return n * getFactorial02(n - 1);
    }
}
